package com.macro.mall.model;

import cn.hutool.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * common实体类
 *
 * @author gaodx
 *
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Common implements Serializable{
	/***/
    @ApiModelProperty(value = "")
	private Integer id; 
	/***/
    @ApiModelProperty(value = "")
	private String commonType; 
	/***/
    @ApiModelProperty(value = "")
	private String commonName; 
	/***/
    @ApiModelProperty(value = "")
	private String commonCode; 
	/***/
    @ApiModelProperty(value = "")
	private String commonDesc; 
	/***/
    @ApiModelProperty(value = "")
	private Date createTime; 
	/**
	 * 实例化
	 */
	public Common() {
		super();
	}
	/**
	 * 实例化
	 * 
	 * @param obj
	 */

	public Common(JSONObject obj) {
		this();
		if (obj.get("id") instanceof Number) {
			this.setId(((Number) obj.get("id")).intValue());
		}
		if (obj.get("commonType") instanceof String) {
			this.setCommonType((String) obj.get("commonType"));
		}
		if (obj.get("commonName") instanceof String) {
			this.setCommonName((String) obj.get("commonName"));
		}
		if (obj.get("commonCode") instanceof String) {
			this.setCommonCode((String) obj.get("commonCode"));
		}
		if (obj.get("commonDesc") instanceof String) {
			this.setCommonDesc((String) obj.get("commonDesc"));
		}
		this.setCreateTime((Date) obj.get("createTime"));
	}
	
	/**
	 * 将当前对象转换为JsonObject
	 * 
	 * @return
	 */
	public JSONObject toJson() {
		JSONObject result = new JSONObject();
		if (this.getId() != null) {
			result.put("id",this.getId());
		}
		if (this.getCommonType() != null) {
			result.put("commonType",this.getCommonType());
		}
		if (this.getCommonName() != null) {
			result.put("commonName",this.getCommonName());
		}
		if (this.getCommonCode() != null) {
			result.put("commonCode",this.getCommonCode());
		}
		if (this.getCommonDesc() != null) {
			result.put("commonDesc",this.getCommonDesc());
		}
		if (this.getCreateTime() != null) {
			result.put("createTime",this.getCreateTime());
		}
		return result;
	}


	@Override
	public String toString() {
		return "Common [id=" + id + " , commonType=" + commonType + " , commonName=" + commonName + " , commonCode=" + commonCode + " , commonDesc=" + commonDesc + " , createTime=" + createTime + "  ]";
	
	}
	
	
}
